import type { AxiosPromise } from 'axios'
import request from '@/utils/request'
import type { ClientForm, ClientQuery, ClientVO } from '@/api/system/client/types'

/**
 * 查询客户端管理列表
 * @param query
 * @returns {*}
 */

export function listClient(query?: ClientQuery): AxiosPromise<ClientVO[]> {
  return request({
    url: '/system/client/list',
    method: 'get',
    params: query,
  })
}

/**
 * 查询客户端管理详细
 * @param id
 */
export function getClient(id: string | number): AxiosPromise<ClientVO> {
  return request({
    url: `/system/client/${id}`,
    method: 'get',
  })
}

/**
 * 新增客户端管理
 * @param data
 */
export function addClient(data: ClientForm) {
  return request({
    url: '/system/client',
    method: 'post',
    data,
  })
}

/**
 * 修改客户端管理
 * @param data
 */
export function updateClient(data: ClientForm) {
  return request({
    url: '/system/client',
    method: 'put',
    data,
  })
}

/**
 * 删除客户端管理
 * @param id
 */
export function delClient(id: string | number | Array<string | number>) {
  return request({
    url: `/system/client/${id}`,
    method: 'delete',
  })
}

/**
 * 状态修改
 * @param clientId 客户端id
 * @param status 状态
 */
export function changeStatus(clientId: string, status: string) {
  const data = {
    clientId,
    status,
  }
  return request({
    url: '/system/client/changeStatus',
    method: 'put',
    data,
  })
}
